import { useState } from 'react';
import { copyText } from '@/utils/front';
import ToolTips from '../ToolTips';
import './index.scss';
const CopyButton = ({ copyText: text }: { copyText: string }) => {
  const [showTips, setShowTips] = useState(false);
  const [tipsText, setTipsText] = useState('Copy');
  // const tempRef = useRef<any>(null);
  const handleCopy = () => {
    copyText(text);
    setTipsText('Copied to clipboard');
  };
  return (
    <div className="common-copybutton" onClick={handleCopy}>
      <ToolTips text={tipsText}>
        <span className="iconfont icon-copy" />
      </ToolTips>
    </div>
  );
};

export default CopyButton;
